STEP 14: Using the distance formula, we can calculate the distance between two sprites. This formula uses our delta_y (rise) and delta_x (run) to calculate the straight-line distance.
The distance formula is based on the Pythagorean Theorem (a2 + b2 = c2), so solving for c will give us the distance.
- From , drag out Distance Formula to the bottom of your code.
- Now that we know how far apart Emma and Michael are, we can make something happen if they are too close!
To navigate the page using the TAB key, first press ESC to exit the code editor.